Telegram Group & Telegram Channel
📌 Разбор Python-задачи

Если вы ответил 2 — это ловушка

def func(a, b):
res = a + b

res = func(1, 1)
print(res)


На первый взгляд кажется, что res = 2. Но нет.

➡️ Что происходит

1. Функция func(a, b) складывает a + b и сохраняет в переменную res внутри функции.

2. Но! Функция ничего не возвращает. В Python по умолчанию любая функция без return возвращает None.

3. Следовательно, res = func(1, 1) присваивает None.

4. На экран выводится None.

📎 Пост с задачей

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2779
Create:
Last Update:

📌 Разбор Python-задачи

Если вы ответил 2 — это ловушка

def func(a, b):
res = a + b

res = func(1, 1)
print(res)


На первый взгляд кажется, что res = 2. Но нет.

➡️ Что происходит

1. Функция func(a, b) складывает a + b и сохраняет в переменную res внутри функции.

2. Но! Функция ничего не возвращает. В Python по умолчанию любая функция без return возвращает None.

3. Следовательно, res = func(1, 1) присваивает None.

4. На экран выводится None.

📎 Пост с задачей

Proglib Academy #буст

BY Proglib.academy | IT-курсы


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/proglib_academy/2779

View MORE
Open in Telegram


Proglib academy | IT курсы Telegram | DID YOU KNOW?

Date: |

Why Telegram?

Telegram has no known backdoors and, even though it is come in for criticism for using proprietary encryption methods instead of open-source ones, those have yet to be compromised. While no messaging app can guarantee a 100% impermeable defense against determined attackers, Telegram is vulnerabilities are few and either theoretical or based on spoof files fooling users into actively enabling an attack.

What is Secret Chats of Telegram

Secret Chats are one of the service’s additional security features; it allows messages to be sent with client-to-client encryption. This setup means that, unlike regular messages, these secret messages can only be accessed from the device’s that initiated and accepted the chat. Additionally, Telegram notes that secret chats leave no trace on the company’s services and offer a self-destruct timer.

Proglib academy | IT курсы from id


Telegram Proglib.academy | IT-курсы
FROM USA